package com.kevin.utility.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 问题状态枚举类型
 * @author Administrator
 *
 */
public enum ProblemStatus {
	NEW("10","新建"),
	WAIT_START("14","未开始"),
	DESIGNING("20","设计中"),
	WAIT_DEVELOP("30","已设计待开发"),
	DEVELOPING("40","开发中"),
	WAIT_ONLIE("50","已开发待上线"),
	WAIT_CHECK("60","已上线未验证"),
	CHECK_FAIL("70","验证不通过"),
	CHECK_SUCCESS("80","已验证"),
	NEED_NOT_SOLVE("90","无需解决"),
	RUNING("91","待观察"),
	RE_ANALYSE("92","重分析");
	
	private String key;
	private String value;
	
	private ProblemStatus(String key,String value){
		this.key = key;
		this.value = value;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
	public static Map<String,String> getMap(){
		Map<String,String> map = new LinkedHashMap<String, String>();
		for(ProblemStatus obj:ProblemStatus.values()){
			map.put(obj.key,obj.value);
		}
		return map;
	}
	
	public static boolean problemCanVerify(String status){
		if(status.equalsIgnoreCase(ProblemStatus.NEED_NOT_SOLVE.getValue())
				||status.equalsIgnoreCase(ProblemStatus.RUNING.getValue())
				||status.equalsIgnoreCase(ProblemStatus.WAIT_CHECK.getValue())
		){
			return true;
		}
		return false;
	}
	
	public static List<Map<String,String>> setToList(){
		Map<String,String> statusMap = ProblemStatus.getMap();
        Map<String,String> tempMap;
        List<Map<String,String>> targetStatusList = new ArrayList<Map<String,String>>();
        for(String key:statusMap.keySet()){
        	tempMap = new HashMap<String, String>();
        	tempMap.put("key", key);
        	tempMap.put("value", statusMap.get(key));
        	targetStatusList.add(tempMap);
        }
        return targetStatusList;
	}
}
